package designpattern.factory.simplefactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

// pizza 商店
public class OrderPizza {
    private PizzaFactory pizzaFactory;

    public void setPizzaFactory(PizzaFactory pizzaFactory) {
        this.pizzaFactory = pizzaFactory;
    }

    //订购pizza
    public void order(){
        do {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            try {
                String orderType = br.readLine();
                if(!orderType.equals("cheese") && !orderType.equals("greek")){
                    br.close();
                    return;
                }
                pizzaFactory.createPizza(orderType);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }while (true);
    }
}


